<template>
    <div id="subtempl">
        <div class="left num " @click="substrict()">-</div>
        <div class="center num">{{count}}</div>
        <div class="right num" @click="add()">+</div>
    </div>
</template>
<script>
 export default {
  props:['initcount','goodsid'],
  data(){
      return{
          count:1,
          resobj:{goodsid:0,type:'add'}
      }
  },
     created(){
      this.count=this.initcount;
     },
 methods:{
     substrict(){
         this.count--;
         if(this.count <1){
             this.count =1;
             return;
         }
         this.sendmessage('substrict');
     },
     add(){
         this.count++;
         this.sendmessage('add');
     },
     sendmessage(type){
         this.resobj.type=type;
         this.resobj.goodsid=this.goodsid;
         this.$emit("cardataobj",this.resobj);
     }
 }
 }
</script>
<style scoped>
#subtempl .num{
    display: inline-block;
    width: 35px;
    height: 25px;
    line-height: 25px;
    text-align: center;
    border: 1px solid rgba(0,0,0,0.6);
}
</style>